import { LGXEnums } from "../../common/sysenum";

var ExplodeSvc = {}
ExplodeSvc.explode = function(graph,dataManger){
    let symbol = graph.getSymbol();
    if (!symbol || graph.graphType == LGXEnums.LGXGraphType.LineGraph_type
        || graph.graphType == LGXEnums.LGXGraphType.CommBusGraph_type){
        return ;
    }

    let blockPos = graph.getPosCopy();
    let len = symbol.m_GraphUnitLst.length;
    for (let i = 0; i < len; i++) {
        let unitGraph = symbol.m_GraphUnitLst[i];
        this.clone2NewGraph(unitGraph,blockPos,dataManger);
    }
    graph.setUseful(0);
}

ExplodeSvc.clone2NewGraph = function(unitGraph,blockPos,dataManger){
    let copyGraph = dataManger.creatNewGraph4InnerSvc(unitGraph.getType());
    if (!copyGraph){
        return ;
    }
    let info = unitGraph.toInfo();
    info.translate(blockPos.x, blockPos.y);
    copyGraph.assignInfo(info);
    copyGraph.calScope(1);
}
export {ExplodeSvc}